---
apiVersion: v1
kind: Secret
metadata:
  name: cloud-data-discoverer
  namespace: d8-cloud-provider-openstack
  {{- include "helm_lib_module_labels" (list . (dict "app" "cloud-data-discoverer")) | nindent 2 }}
type: Opaque
data:
  authURL: {{ .Values.cloudProviderOpenstack.internal.connection.authURL | b64enc | quote }}
  domainName: {{ .Values.cloudProviderOpenstack.internal.connection.domainName | b64enc | quote }}
  username: {{ .Values.cloudProviderOpenstack.internal.connection.username | b64enc | quote }}
  password: {{ .Values.cloudProviderOpenstack.internal.connection.password | b64enc | quote }}
  region: {{ .Values.cloudProviderOpenstack.internal.connection.region | b64enc | quote }}
{{- if hasKey .Values.cloudProviderOpenstack.internal.connection "tenantName" }}
  tenantName: {{ .Values.cloudProviderOpenstack.internal.connection.tenantName | b64enc | quote }}
{{- end }}
{{- if hasKey .Values.cloudProviderOpenstack.internal.connection "tenantID" }}
  tenantID: {{ .Values.cloudProviderOpenstack.internal.connection.tenantID | b64enc | quote }}
{{- end }}
{{- if hasKey .Values.cloudProviderOpenstack.internal.connection "caCert" }}
  ca.crt: {{ .Values.cloudProviderOpenstack.internal.connection.caCert | b64enc | quote }}
{{- end }}

  # additionals config
  {{- $internal := .Values.cloudProviderOpenstack.internal }}
  {{- $openstackValues := dict }}
  {{- if hasKey $internal "instances" }}
    {{- $_ := set $openstackValues "instances" $internal.instances }}
  {{- end }}
  {{- if hasKey $internal "zones" }}
    {{- $_ := set $openstackValues "zones" $internal.zones }}
  {{- end }}
  moduleConfig: {{ $openstackValues | toJson | b64enc | quote }}
